package src.multithreading;

public class PriorityTest {
    public static void main(String[] args) {
        //主函数默认优先级
        System.out.println(Thread.currentThread().getName()+"---MAIN--->"+Thread.currentThread().getPriority());

        MyPriority myPriority = new MyPriority();
        Thread t1 = new Thread(myPriority);
        Thread t2 = new Thread(myPriority);
        Thread t3 = new Thread(myPriority);
        Thread t4 = new Thread(myPriority);
        Thread t5 = new Thread(myPriority);
        Thread t6 = new Thread(myPriority);
        Thread t7 = new Thread(myPriority);
        Thread t8 = new Thread(myPriority);

        t1.start();
        //t1.setPriority(1);

        t2.setPriority(2);
        t2.start();

        t3.setPriority(3);
        t3.start();

        t4.setPriority(4);
        t4.start();

        t5.setPriority(Thread.NORM_PRIORITY);
        t5.start();

        t6.setPriority(6);
        t6.start();

        t7.setPriority(Thread.MIN_PRIORITY);
        t7.start();

        t8.setPriority(Thread.MAX_PRIORITY);
        t8.start();

    }
}

class MyPriority implements Runnable{
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"-->"+Thread.currentThread().getPriority());
    }
}